import { MockMethod } from 'vite-plugin-mock'
import { SUCCESS_CODE } from '@/constants'

const timeout = 1000

const adminList = [
  {
    path: '/bill',
    component: '#',
    name: 'Bill',
    redirect: '/bill/list',
    meta: {
      title: '运单管理',
      icon: 'carbon:skill-level-advanced'
    },
    children: [
      {
        path: 'list',
        name: 'BillList',
        component: 'views/Bill/index',
        meta: {
          title: '运单列表'
        }
      },
      {
        path: 'create',
        name: 'BillCreate',
        component: 'views/Bill/create',
        meta: {
          title: '运单创建--废弃'
        }
      },
      {
        path: 'createcopy',
        name: 'BillCreateCopy',
        component: 'views/Bill/createCopy',
        meta: {
          title: '运单创建Copy'
        }
      }
    ]
  }
]

const testList: string[] = ['/bill', '/bill/list', '/bill/create', '/bill/createcopy']

export default [
  // 列表接口
  {
    url: '/mock/role/list',
    method: 'get',
    timeout,
    response: ({ query }) => {
      const { roleName } = query
      return {
        code: SUCCESS_CODE,
        data: roleName === 'admin' ? adminList : testList
      }
    }
  }
] as MockMethod[]
